package com.xycake.controller.client;

import com.xycake.entity.Goods;
import com.xycake.entity.User;
import com.xycake.service.HomeService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    @RequestMapping("/init")
    public Map<String, Object> init(HttpSession httpSession) {
        User loginUser = (User) httpSession.getAttribute("loginUser");
        Map<String, Object> map = new HashMap<>();
        map.put("showName", loginUser.getShowName());
//        map.put("menus", mainService.selectMenuByRoleId(loginUser.getRoleId()));
        return map;
    }

    @RequestMapping("/index")
    public Map<String,Object> xycakeHome(){
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("data", homeService.selectAllGoods());
        return map;
    }



}
